<?php

class AdminService
{
    public static function getUserRole($userid){
        if(empty($userid)){
            return false;
        }
        $adminModel = new AdminModule();
        $data = $adminModel->getUserRole($userid);
        return $data;
    }

    public static function getUserPrivArray($userid){
        // 查询管理员拥有的角色
        $roles = self::getUserRole($userid);

        // 查询管理员权限项
        $roleModule = new RoleModule();
        $p_data = $roleModule->getRolePurview($roles);
        $priv_arr = array();
        if($p_data){
            foreach($p_data as $value){
                if(in_array($value, $priv_arr)){
                    continue;
                }else{
                    array_push($priv_arr, $value);
                }
            }
        }
        return $priv_arr;
    }

}